﻿@model List<Category>

@{
    Category currentCategory = ViewBag.CurrentCategory;
    Category category = ViewBag.Category;
}

<div class="mega-menu form-category">
    <div class="dropdown mega-fw">
        <a data-toggle="dropdown" class="dropdown-toggle no-href">
            <span class="title">@currentCategory.DisplayName <b class="caret"></b></span>
        </a>
        <div class="dropdown-menu">
            <div class="row">
                <div class="col-sm-3 col-xs-7" style="border-right: 1px solid #ddd;">
                    @foreach (Category cate in Model.Where(x => x.Level == 3).OrderBy(x => x.DisplayName))
                    {
                        string active = cate.Id == currentCategory.Id ? "active" : "";

                        <p>
                            <a class="@active" href="@Url.Action("Index", "Product", new { categoryNameId = category.NameId, category = cate.NameId })">
                                @cate.DisplayName
                            </a>
                        </p>

                        foreach (Category cate2 in Model.Where(x => x.ParentId == cate.Id))
                        {
                            string active2 = cate2.Id == currentCategory.Id ? "active" : "";

                            <p style="padding-left: 15px;">
                                <a class="@active2" href="@Url.Action("Index", "Product", new { categoryNameId = category.NameId, category = cate2.NameId })">
                                    @cate2.DisplayName
                                </a>
                            </p>

                            foreach (Category cate3 in Model.Where(x => x.ParentId == cate2.Id))
                            {
                                string active3 = cate3.Id == currentCategory.Id ? "active" : "";

                                <p style="padding-left: 30px;">
                                    <a class="@active3" href="@Url.Action("Index", "Product", new { categoryNameId = category.NameId, category = cate3.NameId })">
                                        @cate3.DisplayName
                                    </a>
                                </p>
                            }
                        }
                    }
                </div>
                <div class="col-sm-9 col-xs-5">
                    <div class="row min-padding">
                        @foreach (Category cate in Model.Where(x => x.Level == 2))
                        {
                            string active = cate.Id == currentCategory.Id ? "active" : "";

                            <div class="col-md-3 col-sm-6">
                                <a href="@Url.Action("Index", "Product", new { categoryNameId = cate.NameId })">
                                    <img class="img-thumbnail @active" src="@(cate.ImageUrl ?? "/img/no-image.png?w=250&h=115")" title="@cate.Name" alt="@cate.Name @ViewBag.AltGlobal" />
                                </a>
                            </div>
                        }
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
